<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./mytemplate.js"></script>
</head>
<body>
    <div class="ntx"></div>
</body>
<!--模板-->
<script type="text/html" id="message">
        <div>{{name}}</div>
        <div>{{ age}}</div>
        <div>{{  address}}</div>
        <div>{{sex  }}</div>
    
</script>
<script>
    var data={
        name:'zs',
        age:'18',
        address:'川电机',
        sex:'男'
    }
    //调用模板引擎
    var htmlstr=mytemplate('message',data);
    //渲染html结构
    var ntx=document.querySelector('.ntx');
    ntx.innerHTML=htmlstr;

</script>
</html>